package com.example.base.plugin.moudel;

import com.alibaba.fastjson.JSONObject;
import com.example.base.app.AppFunction;
import com.example.base.utils.Result;
import com.example.base.utils.SpringContextUtils;
import com.example.open.service.OpenUserLoginService;

import java.util.Map;

public class OpenUserPlugin  implements AppFunction {
    @Override
    public String getAppFunctionName() {
        return "appOpenUserLogin";
    }

    @Override
    public Object appFunction(Map<String, Object> objectMap) {
        if(!objectMap.containsKey("userName")){
            return Result.errorInfo("username 不得为空");
        }
        if(!objectMap.containsKey("appName")){
            return Result.errorInfo("appName 不得为空");
        }
        String userName=(String) objectMap.get("userName");
        String appName=(String) objectMap.get("appName");
        OpenUserLoginService loginService= SpringContextUtils.getBean(OpenUserLoginService.class);
        JSONObject jsonObject=loginService.appOpenUserLogin(userName,appName);
        return jsonObject;
    }
}
